
#Open Sitka configuration file
$sitkaConfigurationPath = (resolve-path "..\solution\LitwareHR\LitwareHR.Portfolio.Deployment\bin\Release\LitwareHR.Portfolio.Deployment.exe.config")

$sitkaDoc = New-Object System.Xml.XmlDocument
$sitkaDoc.Load($sitkaConfigurationPath)

$sitkaUsernameNode = $sitkaDoc.selectSingleNode("//configuration/appSettings/add[@key='SitkaUserName']")
$sitkaPasswordNode = $sitkaDoc.selectSingleNode("//configuration/appSettings/add[@key='SitkaPassword']")
$sitkaAuthorityNode = $sitkaDoc.selectSingleNode("//configuration/appSettings/add[@key='DefaultAuthority']")

#Open secure configuration file
$configurationPath = (resolve-path "..\solution\LitwareHR\LitwareHR.Portfolio.SecureHost\web.config")

Set-ItemProperty $configurationPath -name "IsReadOnly" -value $false		

$doc = New-Object System.Xml.XmlDocument
$doc.Load($configurationPath)


$node = $doc.selectSingleNode("//configuration/appSettings/add[@key='SitkaUserName']")
$node.value = $sitkaUsernameNode.value 

$node = $doc.selectSingleNode("//configuration/appSettings/add[@key='SitkaPassword']")
$node.value = $sitkaPasswordNode.value 

$node = $doc.selectSingleNode("//configuration/appSettings/add[@key='DefaultAuthority']")
$node.value = $sitkaAuthorityNode.value 

#Save modifed document

$doc.Save($configurationPath)



#Open unsecure configuration file
$configurationPath = (resolve-path "..\solution\LitwareHR\LitwareHR.Portfolio.UnSecureHost\web.config")

Set-ItemProperty $configurationPath -name "IsReadOnly" -value $false		

$doc = New-Object System.Xml.XmlDocument
$doc.Load($configurationPath)

$node = $doc.selectSingleNode("//configuration/appSettings/add[@key='SitkaUserName']")
$node.value = $sitkaUsernameNode.value 

$node = $doc.selectSingleNode("//configuration/appSettings/add[@key='SitkaPassword']")
$node.value = $sitkaPasswordNode.value 

$node = $doc.selectSingleNode("//configuration/appSettings/add[@key='DefaultAuthority']")
$node.value = $sitkaAuthorityNode.value 

#Save modifed document

$doc.Save($configurationPath)



#Open authorization configuration file
$configurationPath = (resolve-path "..\solution\LitwareHR\LitwareHR.Authorization.SvcHost\Web.config")

Set-ItemProperty $configurationPath -name "IsReadOnly" -value $false		

$doc = New-Object System.Xml.XmlDocument
$doc.Load($configurationPath)


$nsmgr = New-Object System.Xml.XmlNamespaceManager($doc.PSBase.NameTable)
$nsmgr.AddNamespace("ns", "http://schemas.microsoft.com/.NetConfiguration/v2.0")

$node = $doc.selectSingleNode("//ns:configuration/ns:appSettings/ns:add[@key='SitkaUserName']", $nsmgr )
$node.value = $sitkaUsernameNode.value 

$node = $doc.selectSingleNode("//ns:configuration/ns:appSettings/ns:add[@key='SitkaPassword']", $nsmgr )
$node.value = $sitkaPasswordNode.value 

$node = $doc.selectSingleNode("//ns:configuration/ns:appSettings/ns:add[@key='DefaultAuthority']", $nsmgr )
$node.value = $sitkaAuthorityNode.value 

#Save modifed document

$doc.Save($configurationPath)


